home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1999 June: Reference Library / Dev.CD Jun 99 RL Disk 1.toast / Technical Documentation / Develop / Additional Articles / Developing Symbiotic Apps / Symbiotic Samples / Symbiotic client source / Trident.cw10_pp / CTridentCmds.cp < prev    next >
Encoding:
Text File  |  1996-10-08  |  5.0 KB  |  157 lines  |  [TEXT/CWIE]

  1. // ===========================================================================
  2. //    CTridentCmd.cp                        ©1993 Metrowerks Inc. All rights reserved.
  3. // ===========================================================================
  4. //
  5.  
  6. #include "CTridentCmds.h"
  7. #include "CTridentApp.h"
  8. #include "CTridentView.h"
  9. #include <LCommander.h>
  10. #include <UException.h>
  11.  
  12. #ifndef __PPCTOOLBOX__
  13. #include <PPCToolbox.h>
  14. #endif
  15.  
  16. #ifndef __TOOLUTILS__
  17. #include <ToolUtils.h>
  18. #endif
  19.  
  20. #ifndef __MIXEDMODE__
  21. #include <MixedMode.h>
  22. #endif
  23. // *********************************  Constants  ************************************* //  all new rD
  24. const OSType kSignature = 'JVLN';
  25. const OSType kWhoType = 'who ';
  26. const OSType kJavType = 'updt';
  27. const short  ppcInternetLocation     = 3;
  28. //TApplicationTrident* gApplicationTrident;
  29.  
  30. // *********************************  Utilities  ************************************* //
  31.  
  32. //--------------------------------------------------------------------------------------------------
  33.  
  34. /*
  35.  *    MyPPCBrowserFilter
  36.  *
  37.  *    Thanks to Eric Berhdahl & Eric Soldan and his Kibitz application for the tips
  38.  *    on how to implement this funciton.
  39.  */
  40.  static  pascal Boolean MyPPCBrowserFilteruptime(LocationNamePtr /* theLocation*/ , PortInfoPtr thePortInfo)
  41. {
  42.     OSType    type;
  43.  
  44.      if (thePortInfo->name.portKindSelector == ppcByString)
  45.       {
  46.           BlockMove(thePortInfo->name.u.portTypeStr + 1, &type, sizeof(type));
  47.           if (type == kSignature)
  48.               return true;
  49.       } else if (thePortInfo->name.portKindSelector == ppcByCreatorAndType)
  50.       {
  51.           if (thePortInfo->name.u.port.portCreator == kSignature &&
  52.               thePortInfo->name.u.port.portType == kJavType)
  53. //              thePortInfo->name.u.port.portType == kWhoType)
  54.               return true;
  55.       }
  56.       return false;
  57. }
  58.  static  pascal Boolean MyPPCBrowserFilterwho(LocationNamePtr /* theLocation*/ , PortInfoPtr thePortInfo)
  59. {
  60.  
  61.       if (thePortInfo->name.portKindSelector == ppcByCreatorAndType)
  62.       {
  63.           if (thePortInfo->name.u.port.portCreator == kSignature &&
  64.               thePortInfo->name.u.port.portType == kWhoType)
  65.               return true;
  66.       }
  67.       return false;
  68.     return FALSE;
  69. }
  70.  
  71. //--------------------------------------------------------------------------------------------------
  72. //extern short gDocumentCount = 0;
  73.  
  74. void MyBrowser(CTridentWindow* theOwner)    // OVERRIDE
  75. {
  76. static PPCFilterUPP gPortFilter = NULL;
  77. //CTridentView* tmpView = (CTridentView*) theOwner->FindPaneByID('winb');
  78. CTridentView* tmpView = (CTridentView*) theOwner->FindPaneByID('winb');
  79. OSType theType;
  80.  
  81. if (tmpView != NULL)
  82.     theType = (OSType) tmpView->GetUserCon();
  83.     
  84. if (gPortFilter == NULL)
  85.     {
  86.     if (theType == kSignature)   //'JVLN'  the normal one
  87.         gPortFilter = NewPPCFilterProc(MyPPCBrowserFilteruptime);
  88.     else
  89.         gPortFilter = NewPPCFilterProc(MyPPCBrowserFilterwho);     //'JVL2'
  90.         
  91.     FailNIL_(gPortFilter);    
  92.     }
  93.     
  94.     PortInfoRec        thePortInfo;
  95.     TargetID        theTargetID;
  96.     OSErr theErr;
  97.     LStr255         windowTitle, tmpString, tmpString2;
  98.     LStr255 theLocNBPType = "\pUNIX PPCToolbox";
  99.     GetIndString(tmpString,kLabelStrings, 2);                //"\pSelect a Unix Server."
  100.     GetIndString(tmpString2,kLabelStrings, 1);                //"\pServers"
  101.  
  102.     theErr = PPCBrowser(tmpString, tmpString2,
  103.              FALSE /* defaultSpecified */, &(theTargetID.location), &thePortInfo, gPortFilter, theLocNBPType);
  104. //    theErr = PPCBrowser(tmpString, tmpString2,
  105. //             FALSE /* defaultSpecified */, &(theTargetID.location), &thePortInfo, NULL, theLocNBPType);
  106.  
  107.     delete gPortFilter;
  108.     gPortFilter = NULL;
  109.     if (theErr == noErr)
  110.         {
  111.         }
  112.         else if (theErr != userCanceledErr)
  113.             //FailOSErr(theErr);
  114.             DebugStr("\p Some error other than userCanceledErr!  Doh!.");
  115.             
  116.         else
  117.             return;
  118.  
  119.     // get the AE Address
  120.     theTargetID.name = thePortInfo.name;
  121.  
  122.         switch (theTargetID.location.locationKindSelector)
  123.     {
  124.         case ppcNoLocation:                        // my own machine
  125. //            fDocument->SetAddress(theTargetID);
  126. //            fDocument->SetPortRefNum(gNumUntitled);
  127. //            fDocument->SetfWindowTitle(CStr255("This is a local node"));
  128.  
  129.             break;
  130.         case ppcNBPLocation:
  131.             theOwner->SetAddress(theTargetID);
  132. //            theErr = PtrToHand(&theTargetID.location.u.nbpEntity.objStr, &testString, 33);
  133.             BlockMove(&theTargetID.location.u.nbpEntity.objStr, &windowTitle, 33);
  134.             theOwner->SetDescriptor((unsigned char *) &windowTitle);
  135.               if (thePortInfo.name.portKindSelector == ppcByString)
  136.                 tmpView->fLegacyCompatable = TRUE;   //need to send heartbeats despite other communication
  137.             break;
  138.         default:
  139.             DebugStr("\p Help me Rhonda.  If you can read this you're too close.");
  140.     }
  141.     
  142.     // lets check the version number
  143.     
  144. //        InvalidateMenus();    //global routine... not sure who the target is in this case.  we'll see.
  145. //        this->WakeupServer();
  146.  
  147.  
  148. //if  (fDocument->Connected())
  149. //            this->CheckVersion();
  150.  
  151.     //    Words of wisdom, the nbpEntity record is trash if the PPC selection is on the same
  152.     //    local node. It is very important to check the locationKindSelector (as above) and
  153.     //    only use the npbEntity record when we have a ppcNBPLocation!!! See IM VI-7 for more
  154.     //    information about this (it's well hidden!)
  155. }
  156.  
  157.